<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="theme-color" content="#222"><meta name="generator" content="Hexo 6.1.0">


  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.1.1/animate.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/themes/green/pace-theme-minimal.css">
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pace/1.2.4/pace.min.js" integrity="sha256-gqd7YTjg/BtfqWSwsJOvndl0Bxc8gFImLEkXQT8+qj0=" crossorigin="anonymous"></script>

<script class="next-config" data-name="main" type="application/json">{"hostname":"liukairui.me","root":"/","images":"/images","scheme":"Muse","darkmode":false,"version":"8.10.1","exturl":false,"sidebar":{"position":"left","display":"hide","padding":18,"offset":12},"copycode":true,"bookmark":{"enable":false,"color":"#222","save":"auto"},"mediumzoom":false,"lazyload":true,"pangu":true,"comments":{"style":"tabs","active":"valine","storage":true,"lazyload":false,"nav":null,"activeClass":"valine"},"stickytabs":false,"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"fadeInDown","post_body":"fadeInDown","coll_header":"fadeInLeft","sidebar":"fadeInUp"}},"prism":false,"i18n":{"placeholder":"搜索...","empty":"没有找到任何搜索结果：${query}","hits_time":"找到 ${hits} 个搜索结果（用时 ${time} 毫秒）","hits":"找到 ${hits} 个搜索结果"},"path":"/search.xml","localsearch":{"enable":true,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false}}</script><script src="/js/config.js"></script>

    <meta name="description" content="BootStrapt是一套UI库，学习的时候应该注意重点在实践而不是理解原理，学习的时候需要常常访问其官网参考文档,主讲:尚硅谷,视频来自B站:BV1YW411T7yy">
<meta property="og:type" content="article">
<meta property="og:title" content="BootStrap 笔记">
<meta property="og:url" content="http://liukairui.me/article/BootStrap%E7%AC%94%E8%AE%B0/">
<meta property="og:site_name" content="LiuKairui Website">
<meta property="og:description" content="BootStrapt是一套UI库，学习的时候应该注意重点在实践而不是理解原理，学习的时候需要常常访问其官网参考文档,主讲:尚硅谷,视频来自B站:BV1YW411T7yy">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2020-10-30T16:00:20.000Z">
<meta property="article:modified_time" content="2021-10-18T06:44:13.589Z">
<meta property="article:author" content="Liu Kairui">
<meta property="article:tag" content="前端">
<meta property="article:tag" content="笔记">
<meta property="article:tag" content="CSS">
<meta property="article:tag" content="BootStrap">
<meta name="twitter:card" content="summary">


<link rel="canonical" href="http://liukairui.me/article/BootStrap%E7%AC%94%E8%AE%B0/">



<script class="next-config" data-name="page" type="application/json">{"sidebar":"","isHome":false,"isPost":true,"lang":"zh-CN","comments":true,"permalink":"http://liukairui.me/article/BootStrap%E7%AC%94%E8%AE%B0/","path":"article/BootStrap笔记/","title":"BootStrap 笔记"}</script>

<script class="next-config" data-name="calendar" type="application/json">""</script>
<title>BootStrap 笔记 | LiuKairui Website</title>
  

  <script src="/js/third-party/analytics/baidu-analytics.js"></script>
  <script async src="https://hm.baidu.com/hm.js?ea07bceb8f5fa721da2ebf01833faa32"></script>



<div class="nindexBK">
<div class="nindexBKC"></div>
<div class="nindex">
  <h1>Hey👋</h1>
  <p style="font-weight: 500; font-size: 2.2em">欢迎访问Liu Kairui的个人站.</p>
  <p>
      我是一个来自重庆的在校大学生, 偏爱于前端技术<!--与OS设计-->, 偶尔使用 JS / Go 进行轻量项目开发, 欢迎访问我的
      <a href="https://github.com/KairuiLiu" target="_blank"><i class="fab fa-github-alt"></i> GitHub</a> .
  </p>
  <p>
      这个网站主要用来存储学习 / 瞎搞的笔记, 同时提供了邮件、图床等服务. 对于一些自认为有趣的<a href="javascript:;" id="myProj">项目</a>, 我也会将项目介绍, 文档, 甚至是设计指南发布在这里.
  </p>
  <ul>
    <li><p><a href="/artrank/" target="_blank">ArtRank</a>: 基于Node.JS的PageRank文献管理推荐系统</p></li>
    <li><p><a href="/gooj/" target="_blank">GoOJ</a>: 基于Golang的高校在线评测系统</p></li>
    <li><p><a href="/projects/" target="_blank">更多 <i class="fas fa-angle-right"></i></a></p></li>

  </ul>
  <p>
      可以在这些平台找到我: 
      <a href="https://www.zhihu.com/people/liu-kai-rui-18" target="_blank">知乎</a>,
      <a href="https://space.bilibili.com/33238144" target="_blank">bilibili</a>
      和
      <a href="https://www.coolapk.com/u/805314?from=qr" target="_blank">酷安</a>.
  </p>

  <p>
      下滑即可进入博客 <i class="fas fa-arrow-down"></i>
  </p>
</div>
</div>  

 
<script>
  var OriginTitile = document.title;
  var titleTime;
  document.addEventListener("visibilitychange", function() {
    if (document.hidden) {
      document.title = "谢谢离开 | " + OriginTitile;
      clearTimeout(titleTime);
    } else {
      document.title = "欢迎归来 | " + OriginTitile;
      titleTime = setTimeout(function() {
        document.title = OriginTitile;
      }, 2000);
    }
  });
</script>


<script>
  function checkIndex(){
    let nindexItems = [[".nindexBK","display","block","none"],[".headband","display","none","block"],["div.toggle.sidebar-toggle","visibility","hidden","visible"]]; // ,["button.darkmode-toggle","visibility","hidden","visible"]];
    let isIndex = new RegExp("^(\/){0,1}(index){0,1}(\.html){0,1}(/)*$").test(location.pathname);
    let backCanvas = document.querySelector(".nindexBK");
    nindexItems.dispShift = function (stat){this.forEach((e) => {try{document.querySelector(e[0]).style[e[1]]=e[2+stat];}catch{}})}
    if(isIndex){
      nindexItems.dispShift(0);
      window.onscroll=function(){
        if(document.documentElement.scrollTop>backCanvas.offsetHeight*1.05){
          nindexItems.dispShift(1);window.onscroll=null;
        }
      }
      document.querySelector("#myProj").onclick=()=>{
        let projlist = document.querySelector(".nindex>ul");
        projlist.className.indexOf("ulactive")==-1?projlist.classList.add("ulactive"):projlist.classList.remove("ulactive")
      }
    }else nindexItems.dispShift(1);
  }
  checkIndex();
</script>

<!--<script src="https://sdk.jinrishici.com/v2/browser/jinrishici.js" charset="utf-8"></script>-->

  <noscript>
    <link rel="stylesheet" href="/css/noscript.css">
  </noscript>
<link rel="alternate" href="/atom.xml" title="LiuKairui Website" type="application/atom+xml">
<style>.darkmode--activated{--body-bg-color:#282828;--content-bg-color:#333;--card-bg-color:#555;--text-color:#ccc;--blockquote-color:#bbb;--link-color:#ccc;--link-hover-color:#eee;--brand-color:#ddd;--brand-hover-color:#ddd;--table-row-odd-bg-color:#282828;--table-row-hover-bg-color:#363636;--menu-item-bg-color:#555;--btn-default-bg:#222;--btn-default-color:#ccc;--btn-default-border-color:#555;--btn-default-hover-bg:#666;--btn-default-hover-color:#ccc;--btn-default-hover-border-color:#666;--highlight-background:#282b2e;--highlight-foreground:#a9b7c6;--highlight-gutter-background:#34393d;--highlight-gutter-foreground:#9ca9b6}.darkmode--activated img{opacity:.75}.darkmode--activated img:hover{opacity:.9}.darkmode--activated code{color:#69dbdc;background:0 0}button.darkmode-toggle{z-index:9999}.darkmode-ignore,img{display:flex!important}</style></head>

<body itemscope itemtype="http://schema.org/WebPage" class="use-motion">
  <div class="headband"></div>

  <main class="main">
    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏" role="button">
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
        <span class="toggle-line"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <i class="logo-line"></i>
      <p class="site-title">LiuKairui Website</p>
      <i class="logo-line"></i>
    </a>
      <p class="site-subtitle" itemprop="description">要有信仰</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
        <i class="fa fa-search fa-fw fa-lg"></i>
    </div>
  </div>
</div>



<nav class="site-nav">
  <ul class="main-menu menu">
        <li class="menu-item menu-item-home"><a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a></li>
        <li class="menu-item menu-item-categories"><a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类</a></li>
        <li class="menu-item menu-item-tags"><a href="/tags/" rel="section"><i class="fas fa-hashtag fa-fw"></i>标签</a></li>
        <li class="menu-item menu-item-收藏夹"><a href="/favorites/" rel="section"><i class="fab fa-gratipay fa-fw"></i>收藏夹</a></li>
        <li class="menu-item menu-item-留言板"><a href="/messageBoard/" rel="section"><i class="fab fa-facebook-messenger fa-fw"></i>留言板</a></li>
        <li class="menu-item menu-item-项目"><a href="/projects/" rel="section"><i class="fa fa-satellite fa-fw"></i>项目</a></li>
        <li class="menu-item menu-item-图床"><a href="http://img.liukairui.me/" rel="noopener" target="_blank"><i class="fa fa-bed fa-fw"></i>图床</a></li>
        <li class="menu-item menu-item-云ide"><a href="http://vsc.liukairui.me/" rel="noopener" target="_blank"><i class="fas fa-code fa-fw"></i>云IDE</a></li>
        <li class="menu-item menu-item-about"><a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a></li>
        <li class="menu-item menu-item-邮箱"><a href="http://mail.liukairui.me/mail" rel="noopener" target="_blank"><i class="fas fa-envelope-open-text fa-fw"></i>邮箱</a></li>
        <li class="menu-item menu-item-rss"><a href="/atom.xml" rel="section"><i class="fa fa-rss fa-fw"></i>RSS</a></li>
      <li class="menu-item menu-item-search">
        <a role="button" class="popup-trigger"><i class="fa fa-search fa-fw"></i>搜索
        </a>
      </li>
  </ul>
</nav>



  <div class="search-pop-overlay">
    <div class="popup search-popup"><div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input-container">
    <input autocomplete="off" autocapitalize="off" maxlength="80"
           placeholder="搜索..." spellcheck="false"
           type="search" class="search-input">
  </div>
  <span class="popup-btn-close" role="button">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="search-result-container no-result">
  <div class="search-result-icon">
    <i class="fa fa-spinner fa-pulse fa-5x"></i>
  </div>
</div>

    </div>
  </div>

</div>
        
  
  <div class="toggle sidebar-toggle" role="button">
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
    <span class="toggle-line"></span>
  </div>

  <aside class="sidebar">

    <div class="sidebar-inner sidebar-nav-active sidebar-toc-active">
      <ul class="sidebar-nav">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <div class="sidebar-panel-container">
        <!--noindex-->
        <div class="post-toc-wrap sidebar-panel">
            <div class="post-toc animated"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#bootstrap%E7%9A%84%E5%BC%95%E5%85%A5"><span class="nav-number">1.</span> <span class="nav-text">BootStrap的引入</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%B5%81%E4%BD%93%E5%AE%B9%E5%99%A8"><span class="nav-number">2.</span> <span class="nav-text">流体容器</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%9B%BA%E5%AE%9A%E5%AE%B9%E5%99%A8"><span class="nav-number">3.</span> <span class="nav-text">固定容器</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%8F%8A%E6%A0%BC%E5%B8%83%E5%B1%80%E7%8F%8A%E6%A0%BC%E7%B3%BB%E7%BB%9F"><span class="nav-number">4.</span> <span class="nav-text">珊格布局（珊格系统）</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#bootstrap-%E8%AF%BB%E6%BA%90%E7%A0%81"><span class="nav-number">5.</span> <span class="nav-text">BootStrap 读源码</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#bootstrap-%E5%AE%9E%E4%BE%8B"><span class="nav-number">6.</span> <span class="nav-text">Bootstrap 实例</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#bootstrap-%E7%9A%84%E5%88%97%E6%8E%92%E5%BA%8F%E5%92%8C%E5%88%97%E5%81%8F%E7%A7%BB"><span class="nav-number">7.</span> <span class="nav-text">BootStrap 的列排序和列偏移</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#bootstrap-%E7%9A%84%E5%93%8D%E5%BA%94%E5%BC%8F%E5%B7%A5%E5%85%B7%E8%AF%BB%E6%BA%90%E7%A0%81%E5%AD%A6%E5%B7%A5%E5%85%B7"><span class="nav-number">8.</span> <span class="nav-text">BootStrap
的响应式工具[读源码学工具]</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%8F%8A%E6%A0%BC%E6%A8%A1%E5%9E%8B%E8%AE%BE%E8%AE%A1%E7%9A%84%E7%B2%BE%E5%A6%99%E4%B9%8B%E5%A4%84"><span class="nav-number">9.</span> <span class="nav-text">珊格模型设计的精妙之处</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#bootstrap-%E5%AE%9A%E5%88%B6%E5%8C%96"><span class="nav-number">10.</span> <span class="nav-text">BootStrap 定制化</span></a></li></ol></div>
        </div>
        <!--/noindex-->

        <div class="site-overview-wrap sidebar-panel">
          <div class="site-author site-overview-item animated" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Liu Kairui"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">Liu Kairui</p>
  <div class="site-description" itemprop="description">LiuKairui Persional Website</div>
</div>
<div class="site-state-wrap site-overview-item animated">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        <a href="/archives/">
          <span class="site-state-item-count">45</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
          <a href="/categories/">
        <span class="site-state-item-count">24</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
          <a href="/tags/">
        <span class="site-state-item-count">53</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author site-overview-item animated">
      <span class="links-of-author-item">
        <a href="https://github.com/KairuiLiu" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;KairuiLiu" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:tclkr@live.com" title="E-Mail → mailto:tclkr@live.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://qm.qq.com/cgi-bin/qm/qr?k=oaf3ToOlN17hr5sHV98bT8qxsNYGaw5L&noverify=0" title="QQ → https:&#x2F;&#x2F;qm.qq.com&#x2F;cgi-bin&#x2F;qm&#x2F;qr?k&#x3D;oaf3ToOlN17hr5sHV98bT8qxsNYGaw5L&amp;noverify&#x3D;0" rel="noopener" target="_blank"><i class="fab fa-qq fa-fw"></i>QQ</a>
      </span>
      <span class="links-of-author-item">
        <a href="/atom.xml" title="RSS → &#x2F;atom.xml"><i class="fa fa-rss fa-fw"></i>RSS</a>
      </span>
      <span class="links-of-author-item">
        <a href="https://liukairui.blog.csdn.net/" title="CSDN → https:&#x2F;&#x2F;liukairui.blog.csdn.net" rel="noopener" target="_blank"><i class="fab fa-cuttlefish fa-fw"></i>CSDN</a>
      </span>
      <span class="links-of-author-item">
        <a href="http://liukairui.cc/" title="国内站点 → http:&#x2F;&#x2F;liukairui.cc" rel="noopener" target="_blank"><i class="fa fa-globe fa-fw"></i>国内站点</a>
      </span>
  </div>
  <div class="cc-license site-overview-item animated" itemprop="license">
    <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" class="cc-opacity" rel="noopener" target="_blank"><img src="https://cdnjs.cloudflare.com/ajax/libs/creativecommons-vocabulary/2020.11.3/assets/license_badges/small/by_nc_sa.svg" alt="Creative Commons"></a>
  </div>


  <div class="links-of-blogroll site-overview-item animated">
    <div class="links-of-blogroll-title"><i class="fa fa-link fa-fw"></i>
      友情链接
    </div>
    <ul class="links-of-blogroll-list">
        <li class="links-of-blogroll-item">
          <a href="https://paste.ubuntu.com/" title="https:&#x2F;&#x2F;paste.ubuntu.com&#x2F;" rel="noopener" target="_blank">Ubuntu Pastebin</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="https://send.firefox.com/" title="https:&#x2F;&#x2F;send.firefox.com&#x2F;" rel="noopener" target="_blank">Firefox Send</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="https://jkwzs.cn/" title="https:&#x2F;&#x2F;jkwzs.cn&#x2F;" rel="noopener" target="_blank">南花醉笔丶の个人博客</a>
        </li>
        <li class="links-of-blogroll-item">
          <a href="https://ywrby.cn/" title="https:&#x2F;&#x2F;ywrby.cn&#x2F;" rel="noopener" target="_blank">Ywrby个人博客</a>
        </li>
    </ul>
  </div>

        </div>
      </div>
    </div>
  </aside>
  <div class="sidebar-dimmer"></div>


    </header>

    
  <div class="back-to-top" role="button" aria-label="返回顶部">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>

<noscript>
  <div class="noscript-warning">Theme NexT works best with JavaScript enabled</div>
</noscript>


    <div class="main-inner post posts-expand">


  


<div class="post-block">
  
  

  <article itemscope itemtype="http://schema.org/Article" class="post-content" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://liukairui.me/article/BootStrap%E7%AC%94%E8%AE%B0/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="Liu Kairui">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="LiuKairui Website">
      <meta itemprop="description" content="LiuKairui Persional Website">
    </span>
    
    <span hidden itemprop="post" itemscope itemtype="http://schema.org/CreativeWork">
      <meta itemprop="name" content="BootStrap 笔记 | LiuKairui Website">
      <meta itemprop="description" content="BootStrapt是一套UI库，学习的时候应该注意重点在实践而不是理解原理，学习的时候需要常常访问其官网参考文档,主讲:尚硅谷,视频来自B站:BV1YW411T7yy">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          BootStrap 笔记
        </h1>

        <div class="post-meta-container">
          <div class="post-meta">
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-calendar"></i>
      </span>
      <span class="post-meta-item-text">发表于</span>

      <time title="创建时间：2020-10-31 00:00:20" itemprop="dateCreated datePublished" datetime="2020-10-31T00:00:20+08:00">2020-10-31</time>
    </span>
    <span class="post-meta-item">
      <span class="post-meta-item-icon">
        <i class="far fa-folder"></i>
      </span>
      <span class="post-meta-item-text">分类于</span>
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%89%8D%E7%AB%AF/" itemprop="url" rel="index"><span itemprop="name">前端</span></a>
        </span>
          ，
        <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
          <a href="/categories/%E5%89%8D%E7%AB%AF/CSS/" itemprop="url" rel="index"><span itemprop="name">CSS</span></a>
        </span>
    </span>

  
    <span id="/article/BootStrap%E7%AC%94%E8%AE%B0/" class="post-meta-item leancloud_visitors" data-flag-title="BootStrap 笔记" title="阅读次数">
      <span class="post-meta-item-icon">
        <i class="far fa-eye"></i>
      </span>
      <span class="post-meta-item-text">阅读次数：</span>
      <span class="leancloud-visitors-count"></span>
    </span>
  
  <span class="post-meta-item">
    
    <span class="post-meta-item-icon">
      <i class="far fa-comment"></i>
    </span>
    <span class="post-meta-item-text">Valine：</span>
  
    <a title="valine" href="/article/BootStrap%E7%AC%94%E8%AE%B0/#valine-comments" itemprop="discussionUrl">
      <span class="post-comments-count valine-comment-count" data-xid="/article/BootStrap%E7%AC%94%E8%AE%B0/" itemprop="commentCount"></span>
    </a>
  </span>
  
  

<script>
    CONFIG.hostname = location.hostname;
</script>
    <span class="post-meta-break"></span>
    <span class="post-meta-item" title="本文字数">
      <span class="post-meta-item-icon">
        <i class="far fa-file-word"></i>
      </span>
      <span class="post-meta-item-text">本文字数：</span>
      <span>16k</span>
    </span>
    <span class="post-meta-item" title="阅读时长">
      <span class="post-meta-item-icon">
        <i class="far fa-clock"></i>
      </span>
      <span class="post-meta-item-text">阅读时长 &asymp;</span>
      <span>15 分钟</span>
    </span>
</div>

            <div class="post-description">BootStrapt是一套UI库，学习的时候应该注意重点在实践而不是理解原理，学习的时候需要常常访问其官网参考文档,主讲:尚硅谷,视频来自B站:BV1YW411T7yy</div>
        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">
        <p>BootStrapt是一套UI库，学习的时候应该注意重点在实践而不是理解原理，学习的时候需要常常访问其<a
target="_blank" rel="noopener" href="https://v3.bootcss.com/">官网参考文档</a></p>
<h2 id="bootstrap的引入">BootStrap的引入</h2>
<p>BootStrapt是使用Less/Sass写的UI库，可以在官网下载的到其调用库，Less源码，Sass源码，其中压缩包带Dist的是编译后文件，无源码，编译后的文件结构较为简单</p>
<ul>
<li>CSS文件夹： 放置样式文件</li>
<li>fonts文件及：图标字体库</li>
<li>js文件夹：里面有BootStrap的JS文件，那个npm.js为编译时使用的没用</li>
</ul>
<p>使用的时候在HTML代码中引入BootStrap文件，包括</p>
<pre class="language-html" data-language="html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>link</span> <span class="token attr-name">rel</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>stylesheet<span class="token punctuation">"</span></span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>../bootstrap/css/bootstrap.min.css<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>../bootstrap/js/jquery-3.5.1.min.js<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token script"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>../bootstrap/js/bootstrap.min.js<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token script"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span></code></pre>
<p>由于Bootstrap的所有组件都依赖于jQuary所以还需要去jQuary下载一份jQuary的JS文件,顺便就放JS文件夹了。还需要注意的是因为是BootStrap依赖于jQuary所以应该是jQuray在前，BootStrap在后，Js永远在<code>\body</code>后<code>/html</code>前</p>
<p>引入之后我们发现：虽然我们什么都没有写，但是已经有了很多样式了，这些是BootStrap的<strong>自带Normalize.css</strong>,其中值得注意的是所有的元素<code>box-sizing:border-box</code></p>
<h2 id="流体容器">流体容器</h2>
<p>在<code>body</code>中写下如下内容 <pre class="language-html" data-language="html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>container-fluid<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    test
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></code></pre>
我们会看到<code>.container-fluid</code>在审查元素中存在如下样式
<pre class="language-css" data-language="css"><code class="language-css"><span class="token selector">.container-fluid</span> <span class="token punctuation">&#123;</span>
    <span class="token property">padding-right</span><span class="token punctuation">:</span> 15px<span class="token punctuation">;</span>
    <span class="token property">padding-left</span><span class="token punctuation">:</span> 15px<span class="token punctuation">;</span>
    <span class="token property">margin-right</span><span class="token punctuation">:</span> auto<span class="token punctuation">;</span>
    <span class="token property">margin-left</span><span class="token punctuation">:</span> auto<span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span></code></pre>
左右内边距<code>15px</code>,左右外边距<code>auto</code>，相当于是做了一个居中<br />
为<code>.container-fluid</code>加入背景色，修改视口的大小，我们会发现div的大小会随之变化，盒子宽度可以认为是100%</p>
<h2 id="固定容器">固定容器</h2>
<pre class="language-html" data-language="html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>container<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    test
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></code></pre>
<p>类名就是流体容器去掉<code>-fluid</code><br />
可以看到，在全屏下(1080p)盒子并没有撑满整个页面，审查元素看到了很长的媒体查询
<pre class="language-css" data-language="css"><code class="language-css"><span class="token atrule"><span class="token rule">@media</span> <span class="token punctuation">(</span><span class="token property">min-width</span><span class="token punctuation">:</span> 1200px<span class="token punctuation">)</span>
.container</span> <span class="token punctuation">&#123;</span>
    <span class="token property">width</span><span class="token punctuation">:</span> 1170px<span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>
<span class="token atrule"><span class="token rule">@media</span> <span class="token punctuation">(</span><span class="token property">min-width</span><span class="token punctuation">:</span> 992px<span class="token punctuation">)</span>
.container</span> <span class="token punctuation">&#123;</span>
    <span class="token property">width</span><span class="token punctuation">:</span> 970px<span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>
<span class="token atrule"><span class="token rule">@media</span> <span class="token punctuation">(</span><span class="token property">min-width</span><span class="token punctuation">:</span> 768px<span class="token punctuation">)</span>
.container</span> <span class="token punctuation">&#123;</span>
    <span class="token property">width</span><span class="token punctuation">:</span> 750px<span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span></code></pre></p>
<p>里面看到三个阈值</p>
<table>
<thead>
<tr class="header">
<th>意义</th>
<th>代号</th>
<th>屏幕宽度</th>
<th>div宽度</th>
</tr>
</thead>
<tbody>
<tr class="odd">
<td>大屏PC</td>
<td>lg</td>
<td>&gt;=1200</td>
<td>1170</td>
</tr>
<tr class="even">
<td>中屏PC</td>
<td>md</td>
<td>&gt;=992 &lt;1200</td>
<td>970</td>
</tr>
<tr class="odd">
<td>平板</td>
<td>sm</td>
<td>&gt;=768 &lt;992</td>
<td>750</td>
</tr>
<tr class="even">
<td>移动手机</td>
<td>xs</td>
<td>&lt;768</td>
<td>auto</td>
</tr>
</tbody>
</table>
<p><strong>注意</strong>：width的默认值为auto而不是100%，区别是，<code>width:100%</code>时候padding是向外扩，auto是时候是向内扣</p>
<h2 id="珊格布局珊格系统">珊格布局（珊格系统）</h2>
<p>在使用珊格系统的时候我们一般使用固定容器作为他的父元素，使用<code>.row</code>类定义一个行，使用<code>col-XX-YY</code>定义一个列，例如
<pre class="language-html" data-language="html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>container<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>row<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>col-lg-10<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>10<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>col-lg-2<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>2<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></code></pre> 分别着色之后我们可以看到两个div占据了一个固定容器</p>
<p><strong>BootStrap默认分一行为12列，列名上的YY就是占据多少列</strong></p>
<p>但是如果我们将视口宽度调整小一点效果消失了，具体见读源码部分</p>
<h2 id="bootstrap-读源码">BootStrap 读源码</h2>
<p>源码是Less文件，所以在less文件夹里面，再看到里面有一个mixin文件夹放所有的混合，外面的文件可以视为一些入口</p>
<p>我们需要的文件有</p>
<ul>
<li>less/mixin/<code>clearfix.less</code>,<code>grid-framework.less</code>,<code>gird.less</code></li>
<li>less/<code>gird.less</code> 珊格系统的总入口</li>
<li>less/<code>variables.less</code> 定义了所有需要的变量</li>
</ul>
<p>我们只看less/<code>gird.less</code>需要引入的时候从别的地方摘</p>
<pre class="language-less" data-language="less"><code class="language-less"><span class="token selector">.container</span> <span class="token punctuation">&#123;</span>
  <span class="token mixin-usage function">.container-fixed</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>

  <span class="token atrule">@media <span class="token punctuation">(</span>min-width<span class="token punctuation">:</span> @screen-sm-min<span class="token punctuation">)</span></span> <span class="token punctuation">&#123;</span>
    <span class="token property">width</span><span class="token punctuation">:</span> <span class="token variable">@container-sm</span><span class="token punctuation">;</span>
  <span class="token punctuation">&#125;</span>
  <span class="token atrule">@media <span class="token punctuation">(</span>min-width<span class="token punctuation">:</span> @screen-md-min<span class="token punctuation">)</span></span> <span class="token punctuation">&#123;</span>
    <span class="token property">width</span><span class="token punctuation">:</span> <span class="token variable">@container-md</span><span class="token punctuation">;</span>
  <span class="token punctuation">&#125;</span>
  <span class="token atrule">@media <span class="token punctuation">(</span>min-width<span class="token punctuation">:</span> @screen-lg-min<span class="token punctuation">)</span></span> <span class="token punctuation">&#123;</span>
    <span class="token property">width</span><span class="token punctuation">:</span> <span class="token variable">@container-lg</span><span class="token punctuation">;</span>
  <span class="token punctuation">&#125;</span>
<span class="token punctuation">&#125;</span>

<span class="token selector">.container-fluid</span> <span class="token punctuation">&#123;</span>
  <span class="token mixin-usage function">.container-fixed</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>

<span class="token selector">.row</span> <span class="token punctuation">&#123;</span>
  <span class="token mixin-usage function">.make-row</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>

.<span class="token function">make-grid-columns</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token mixin-usage function">.make-grid</span><span class="token punctuation">(</span>xs<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token atrule">@media <span class="token punctuation">(</span>min-width<span class="token punctuation">:</span> @screen-sm-min<span class="token punctuation">)</span></span> <span class="token punctuation">&#123;</span>
  <span class="token mixin-usage function">.make-grid</span><span class="token punctuation">(</span>sm<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>

<span class="token atrule">@media <span class="token punctuation">(</span>min-width<span class="token punctuation">:</span> @screen-md-min<span class="token punctuation">)</span></span> <span class="token punctuation">&#123;</span>
  <span class="token mixin-usage function">.make-grid</span><span class="token punctuation">(</span>md<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>

<span class="token atrule">@media <span class="token punctuation">(</span>min-width<span class="token punctuation">:</span> @screen-lg-min<span class="token punctuation">)</span></span> <span class="token punctuation">&#123;</span>
  <span class="token mixin-usage function">.make-grid</span><span class="token punctuation">(</span>lg<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>
</code></pre>
<p>首先比较困惑的是最后几行，也没有写属于那个类，直接就是个引用和媒体查询(感觉是会作为一个包被其他文件引用)</p>
<p><strong>第一部分 固定容器</strong> <pre class="language-less" data-language="less"><code class="language-less"><span class="token selector">.container</span> <span class="token punctuation">&#123;</span>                                <span class="token comment">// 固定容器</span>
  .<span class="token function">container-fixed</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>                       <span class="token comment">// </span>

  <span class="token atrule">@media <span class="token punctuation">(</span>min-width<span class="token punctuation">:</span> @screen-sm-min<span class="token punctuation">)</span></span> <span class="token punctuation">&#123;</span>
    <span class="token property">width</span><span class="token punctuation">:</span> <span class="token variable">@container-sm</span><span class="token punctuation">;</span>
  <span class="token punctuation">&#125;</span>
  <span class="token atrule">@media <span class="token punctuation">(</span>min-width<span class="token punctuation">:</span> @screen-md-min<span class="token punctuation">)</span></span> <span class="token punctuation">&#123;</span>
    <span class="token property">width</span><span class="token punctuation">:</span> <span class="token variable">@container-md</span><span class="token punctuation">;</span>
  <span class="token punctuation">&#125;</span>
  <span class="token atrule">@media <span class="token punctuation">(</span>min-width<span class="token punctuation">:</span> @screen-lg-min<span class="token punctuation">)</span></span> <span class="token punctuation">&#123;</span>
    <span class="token property">width</span><span class="token punctuation">:</span> <span class="token variable">@container-lg</span><span class="token punctuation">;</span>
  <span class="token punctuation">&#125;</span>
<span class="token punctuation">&#125;</span></code></pre>
这是一个固定容器的<strong>类</strong>，先调用了一个混合，混合去mixin里面找<code>gird.less</code>
<pre class="language-less" data-language="less"><code class="language-less"><span class="token comment">// 固定容器和流体容器的公共样式</span>
<span class="token selector">.container-fixed(<span class="token variable">@gutter</span>: <span class="token variable">@grid-gutter-width</span>)</span> <span class="token punctuation">&#123;</span>
  <span class="token property">margin-right</span><span class="token punctuation">:</span> auto<span class="token punctuation">;</span>
  <span class="token property">margin-left</span><span class="token punctuation">:</span> auto<span class="token punctuation">;</span>
  <span class="token property">padding-left</span><span class="token punctuation">:</span>  <span class="token function">floor</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@gutter</span> <span class="token operator">/</span> 2<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token property">padding-right</span><span class="token punctuation">:</span> <span class="token function">ceil</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@gutter</span> <span class="token operator">/</span> 2<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  &amp;<span class="token punctuation">:</span><span class="token function">extend</span><span class="token punctuation">(</span>.clearfix all<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span></code></pre>
看到有个参数<code>@gutter</code>，同时他还有一个默认参数<code>@grid-gutter-width</code>,对于不知道的变量要去<code>\less\variables.less</code>找，得到<code>@grid-gutter-width:30px</code></p>
<p>这个变量我们称之为<strong>槽宽</strong>，其实就是固定容器默认的内边距</p>
<p>在混合中，我们将设置左右内边距为槽宽的一半向上向下取整，设置左右margin为auto相当于居中，最后混合继承了一个<code>.cldearfix()</code>的所有属性</p>
<p>在固定容器的样式中，之后是三个媒体查询，我们要看一下<code>@screen-XX-min</code>的值，具体要去<code>\less\variables.less</code>，可以看到如下代码
<pre class="language-less" data-language="less"><code class="language-less"><span class="token variable">@screen-xs<span class="token punctuation">:</span></span>                  480px<span class="token punctuation">;</span>
<span class="token variable">@screen-xs-min<span class="token punctuation">:</span></span>              <span class="token variable">@screen-xs</span><span class="token punctuation">;</span>
<span class="token variable">@screen-sm<span class="token punctuation">:</span></span>                  768px<span class="token punctuation">;</span>
<span class="token variable">@screen-sm-min<span class="token punctuation">:</span></span>              <span class="token variable">@screen-sm</span><span class="token punctuation">;</span>
<span class="token variable">@screen-md<span class="token punctuation">:</span></span>                  992px<span class="token punctuation">;</span>
<span class="token variable">@screen-md-min<span class="token punctuation">:</span></span>              <span class="token variable">@screen-md</span><span class="token punctuation">;</span>
<span class="token variable">@screen-lg<span class="token punctuation">:</span></span>                  1200px<span class="token punctuation">;</span>
<span class="token variable">@screen-lg-min<span class="token punctuation">:</span></span>              <span class="token variable">@screen-lg</span><span class="token punctuation">;</span></code></pre>
我们可以看到<code>xs/sm/md/lg</code>分别为<code>480px,768px,992px,1200px</code><br />
继续去找<code>container-xx</code> <pre class="language-less" data-language="less"><code class="language-less"><span class="token variable">@container-tablet<span class="token punctuation">:</span></span>             <span class="token punctuation">(</span>720px <span class="token operator">+</span> <span class="token variable">@grid-gutter-width</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token variable">@container-sm<span class="token punctuation">:</span></span>                 <span class="token variable">@container-tablet</span><span class="token punctuation">;</span>
<span class="token variable">@container-desktop<span class="token punctuation">:</span></span>            <span class="token punctuation">(</span>940px <span class="token operator">+</span> <span class="token variable">@grid-gutter-width</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token variable">@container-md<span class="token punctuation">:</span></span>                 <span class="token variable">@container-desktop</span><span class="token punctuation">;</span>
<span class="token variable">@container-large-desktop<span class="token punctuation">:</span></span>      <span class="token punctuation">(</span>1140px <span class="token operator">+</span> <span class="token variable">@grid-gutter-width</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token variable">@container-lg<span class="token punctuation">:</span></span>                 <span class="token variable">@container-large-desktop</span><span class="token punctuation">;</span></code></pre></p>
<p>三者就是三个屏的固定容器宽度+槽宽</p>
<p>根据移动优先的原则我们把默认给了xs(是auto所以没写)</p>
<p>注意这边的顺序，先小后大，这样巨大平会依次被拦，但是后生效者优先</p>
<p><strong>第二部分 流体容器</strong> <pre class="language-less" data-language="less"><code class="language-less"><span class="token selector">.container-fluid</span> <span class="token punctuation">&#123;</span>
  <span class="token mixin-usage function">.container-fixed</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span></code></pre>
就是固定容器的公共样式</p>
<p><strong>第三部分 行</strong> <pre class="language-less" data-language="less"><code class="language-less"><span class="token selector">.row</span> <span class="token punctuation">&#123;</span>
  <span class="token mixin-usage function">.make-row</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span></code></pre></p>
<p>是个混合，当然是从mixin <code>gird.less</code>里面找</p>
<pre class="language-less" data-language="less"><code class="language-less"><span class="token selector">.make-row(<span class="token variable">@gutter</span>: <span class="token variable">@grid-gutter-width</span>)</span> <span class="token punctuation">&#123;</span>
  <span class="token property">margin-left</span><span class="token punctuation">:</span>  <span class="token function">ceil</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@gutter</span> <span class="token operator">/</span> <span class="token operator">-</span>2<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token property">margin-right</span><span class="token punctuation">:</span> <span class="token function">floor</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@gutter</span> <span class="token operator">/</span> <span class="token operator">-</span>2<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  &amp;<span class="token punctuation">:</span><span class="token function">extend</span><span class="token punctuation">(</span>.clearfix all<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span></code></pre>
<p>左右加了个外边距为<strong>负的</strong>半个槽宽，</p>
<p><strong>第四部分 列</strong> <pre class="language-less" data-language="less"><code class="language-less">.<span class="token function">make-grid-columns</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token mixin-usage function">.make-grid</span><span class="token punctuation">(</span>xs<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token atrule">@media <span class="token punctuation">(</span>min-width<span class="token punctuation">:</span> @screen-sm-min<span class="token punctuation">)</span></span> <span class="token punctuation">&#123;</span>
  <span class="token mixin-usage function">.make-grid</span><span class="token punctuation">(</span>sm<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>

<span class="token atrule">@media <span class="token punctuation">(</span>min-width<span class="token punctuation">:</span> @screen-md-min<span class="token punctuation">)</span></span> <span class="token punctuation">&#123;</span>
  <span class="token mixin-usage function">.make-grid</span><span class="token punctuation">(</span>md<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>

<span class="token atrule">@media <span class="token punctuation">(</span>min-width<span class="token punctuation">:</span> @screen-lg-min<span class="token punctuation">)</span></span> <span class="token punctuation">&#123;</span>
  <span class="token mixin-usage function">.make-grid</span><span class="token punctuation">(</span>lg<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span></code></pre></p>
<p>先调用了一个混合<code>make-grid-columns()</code></p>
<pre class="language-less" data-language="less"><code class="language-less"><span class="token selector">.make-grid-columns()</span> <span class="token punctuation">&#123;</span>
  <span class="token selector">.col(<span class="token variable">@index</span>)</span> <span class="token punctuation">&#123;</span>
    <span class="token atrule">@item<span class="token punctuation">:</span> ~".col-xs-@</span><span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span><span class="token punctuation">,</span> .col<span class="token operator">-</span>sm<span class="token operator">-</span>@<span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span><span class="token punctuation">,</span> .col<span class="token operator">-</span>md<span class="token operator">-</span>@<span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span><span class="token punctuation">,</span> .col<span class="token operator">-</span>lg<span class="token operator">-</span>@<span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span>"<span class="token punctuation">;</span>
    <span class="token mixin-usage function">.col</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@index</span> <span class="token operator">+</span> 1<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token variable">@item</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">&#125;</span>
  <span class="token selector">.col(<span class="token variable">@index</span>, <span class="token variable">@list</span>) when (<span class="token variable">@index</span> =&lt; <span class="token variable">@grid-columns</span>)</span> <span class="token punctuation">&#123;</span> 
    <span class="token atrule">@item<span class="token punctuation">:</span> ~".col-xs-@</span><span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span><span class="token punctuation">,</span> .col<span class="token operator">-</span>sm<span class="token operator">-</span>@<span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span><span class="token punctuation">,</span> .col<span class="token operator">-</span>md<span class="token operator">-</span>@<span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span><span class="token punctuation">,</span> .col<span class="token operator">-</span>lg<span class="token operator">-</span>@<span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span>"<span class="token punctuation">;</span>
    <span class="token mixin-usage function">.col</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@index</span> <span class="token operator">+</span> 1<span class="token punctuation">)</span><span class="token punctuation">,</span> ~<span class="token string">"@&#123;list&#125;, @&#123;item&#125;"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">&#125;</span>
  <span class="token selector">.col(<span class="token variable">@index</span>, <span class="token variable">@list</span>) when (<span class="token variable">@index</span> > <span class="token variable">@grid-columns</span>)</span> <span class="token punctuation">&#123;</span>
    <span class="token selector">@&#123;list&#125;</span> <span class="token punctuation">&#123;</span>
      <span class="token property">position</span><span class="token punctuation">:</span> relative<span class="token punctuation">;</span>
      <span class="token property">min-height</span><span class="token punctuation">:</span> 1px<span class="token punctuation">;</span>
      <span class="token property">padding-left</span><span class="token punctuation">:</span>  <span class="token function">ceil</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@grid-gutter-width</span> <span class="token operator">/</span> 2<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token property">padding-right</span><span class="token punctuation">:</span> <span class="token function">floor</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@grid-gutter-width</span> <span class="token operator">/</span> 2<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
  <span class="token punctuation">&#125;</span>
  .<span class="token function">col</span><span class="token punctuation">(</span>1<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span></code></pre>
<p>看到这个混合，先进去，看到是三个混合，先不管，直接看到唯一一个可以运行的<code>.col(1)</code>，一个变量，进入第一个混合
<pre class="language-less" data-language="less"><code class="language-less"><span class="token selector">.col(<span class="token variable">@index</span>)</span> <span class="token punctuation">&#123;</span>
  <span class="token atrule">@item<span class="token punctuation">:</span> ~".col-xs-@</span><span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span><span class="token punctuation">,</span> .col<span class="token operator">-</span>sm<span class="token operator">-</span>@<span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span><span class="token punctuation">,</span> .col<span class="token operator">-</span>md<span class="token operator">-</span>@<span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span><span class="token punctuation">,</span> .col<span class="token operator">-</span>lg<span class="token operator">-</span>@<span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span>"<span class="token punctuation">;</span>
  <span class="token mixin-usage function">.col</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@index</span> <span class="token operator">+</span> 1<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token variable">@item</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span></code></pre>
尝试跑一下，进入直接就是一个避免编译，然后去调用了一个二元的<code>.col</code>,第一句item得到的是
<pre class="language-none"><code class="language-none">.col-xs-1,.col-sm-1,.col-md-1,.col-lg-1</code></pre> 然后看第二句，成了 <pre class="language-none"><code class="language-none">.col(2,.col-xs-1,.col-sm-1,.col-md-1,.col-lg-1);</code></pre>
第一个混合结束了，因为是<strong>避免编译</strong>所以我们的item是一个变量以字符串的形式传递出去，两个变量，进入第二个混合
<pre class="language-less" data-language="less"><code class="language-less"><span class="token selector">.col(<span class="token variable">@index</span>, <span class="token variable">@list</span>) when (<span class="token variable">@index</span> =&lt; <span class="token variable">@grid-columns</span>)</span> <span class="token punctuation">&#123;</span> 
    <span class="token atrule">@item<span class="token punctuation">:</span> ~".col-xs-@</span><span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span><span class="token punctuation">,</span> .col<span class="token operator">-</span>sm<span class="token operator">-</span>@<span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span><span class="token punctuation">,</span> .col<span class="token operator">-</span>md<span class="token operator">-</span>@<span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span><span class="token punctuation">,</span> .col<span class="token operator">-</span>lg<span class="token operator">-</span>@<span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span>"<span class="token punctuation">;</span>
    <span class="token mixin-usage function">.col</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@index</span> <span class="token operator">+</span> 1<span class="token punctuation">)</span><span class="token punctuation">,</span> ~<span class="token string">"@&#123;list&#125;, @&#123;item&#125;"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span></code></pre></p>
<p>查询到<code>@grid-columns:12;</code>实际上就是默认12列</p>
<p>index=2,进入之后我们又得到一个item <pre class="language-none"><code class="language-none">.col-xs-2,.col-sm-2,.col-md-2,.col-lg-2</code></pre>
这里发生了一个递归，index=3的时候第二句话变成了 <pre class="language-less" data-language="less"><code class="language-less">.<span class="token function">col</span><span class="token punctuation">(</span>3<span class="token punctuation">,</span>.col<span class="token operator">-</span>xs<span class="token operator">-</span>1<span class="token punctuation">,</span>.col<span class="token operator">-</span>sm<span class="token operator">-</span>1<span class="token punctuation">,</span>.col<span class="token operator">-</span>md<span class="token operator">-</span>1<span class="token punctuation">,</span>.col<span class="token operator">-</span>lg<span class="token operator">-</span>1<span class="token punctuation">,</span>.col<span class="token operator">-</span>xs<span class="token operator">-</span>2<span class="token punctuation">,</span>.col<span class="token operator">-</span>sm<span class="token operator">-</span>2<span class="token punctuation">,</span>.col<span class="token operator">-</span>md<span class="token operator">-</span>2<span class="token punctuation">,</span>.col<span class="token operator">-</span>lg<span class="token operator">-</span>2<span class="token punctuation">)</span></code></pre>
由于是避免编译，所以后面仍然是一个变量，我们可以看到index是会比后面的<code>col-xx-y</code>的<code>y</code>大1</p>
<p>我们找到这个递归的边界<code>index=12</code>,也就是<code>index=13</code>的时候不会进入下一次递归，这时候的调用命令应该是
<pre class="language-less" data-language="less"><code class="language-less">.<span class="token function">col</span><span class="token punctuation">(</span>13<span class="token punctuation">,</span>
.col<span class="token operator">-</span>xs<span class="token operator">-</span>1<span class="token punctuation">,</span>.col<span class="token operator">-</span>sm<span class="token operator">-</span>1<span class="token punctuation">,</span>.col<span class="token operator">-</span>md<span class="token operator">-</span>1<span class="token punctuation">,</span>.col<span class="token operator">-</span>lg<span class="token operator">-</span>1<span class="token punctuation">,</span>
.col<span class="token operator">-</span>xs<span class="token operator">-</span>2<span class="token punctuation">,</span>.col<span class="token operator">-</span>sm<span class="token operator">-</span>2<span class="token punctuation">,</span>.col<span class="token operator">-</span>md<span class="token operator">-</span>2<span class="token punctuation">,</span>.col<span class="token operator">-</span>lg<span class="token operator">-</span>2<span class="token punctuation">,</span>
.col<span class="token operator">-</span>xs<span class="token operator">-</span>3<span class="token punctuation">,</span>.col<span class="token operator">-</span>sm<span class="token operator">-</span>3<span class="token punctuation">,</span>.col<span class="token operator">-</span>md<span class="token operator">-</span>3<span class="token punctuation">,</span>.col<span class="token operator">-</span>lg<span class="token operator">-</span>3<span class="token punctuation">,</span>
.col<span class="token operator">-</span>xs<span class="token operator">-</span>4<span class="token punctuation">,</span>.col<span class="token operator">-</span>sm<span class="token operator">-</span>4<span class="token punctuation">,</span>.col<span class="token operator">-</span>md<span class="token operator">-</span>4<span class="token punctuation">,</span>.col<span class="token operator">-</span>lg<span class="token operator">-</span>4<span class="token punctuation">,</span>
.col<span class="token operator">-</span>xs<span class="token operator">-</span>5<span class="token punctuation">,</span>.col<span class="token operator">-</span>sm<span class="token operator">-</span>5<span class="token punctuation">,</span>.col<span class="token operator">-</span>md<span class="token operator">-</span>5<span class="token punctuation">,</span>.col<span class="token operator">-</span>lg<span class="token operator">-</span>5<span class="token punctuation">,</span>
.col<span class="token operator">-</span>xs<span class="token operator">-</span>6<span class="token punctuation">,</span>.col<span class="token operator">-</span>sm<span class="token operator">-</span>6<span class="token punctuation">,</span>.col<span class="token operator">-</span>md<span class="token operator">-</span>6<span class="token punctuation">,</span>.col<span class="token operator">-</span>lg<span class="token operator">-</span>6<span class="token punctuation">,</span>
.col<span class="token operator">-</span>xs<span class="token operator">-</span>7<span class="token punctuation">,</span>.col<span class="token operator">-</span>sm<span class="token operator">-</span>7<span class="token punctuation">,</span>.col<span class="token operator">-</span>md<span class="token operator">-</span>7<span class="token punctuation">,</span>.col<span class="token operator">-</span>lg<span class="token operator">-</span>7<span class="token punctuation">,</span>
.col<span class="token operator">-</span>xs<span class="token operator">-</span>8<span class="token punctuation">,</span>.col<span class="token operator">-</span>sm<span class="token operator">-</span>8<span class="token punctuation">,</span>.col<span class="token operator">-</span>md<span class="token operator">-</span>8<span class="token punctuation">,</span>.col<span class="token operator">-</span>lg<span class="token operator">-</span>8<span class="token punctuation">,</span>
.col<span class="token operator">-</span>xs<span class="token operator">-</span>9<span class="token punctuation">,</span>.col<span class="token operator">-</span>sm<span class="token operator">-</span>9<span class="token punctuation">,</span>.col<span class="token operator">-</span>md<span class="token operator">-</span>9<span class="token punctuation">,</span>.col<span class="token operator">-</span>lg<span class="token operator">-</span>9<span class="token punctuation">,</span>
.col<span class="token operator">-</span>xs<span class="token operator">-</span>10<span class="token punctuation">,</span>.col<span class="token operator">-</span>sm<span class="token operator">-</span>10<span class="token punctuation">,</span>.col<span class="token operator">-</span>md<span class="token operator">-</span>10<span class="token punctuation">,</span>.col<span class="token operator">-</span>lg<span class="token operator">-</span>10<span class="token punctuation">,</span>
.col<span class="token operator">-</span>xs<span class="token operator">-</span>11<span class="token punctuation">,</span>.col<span class="token operator">-</span>sm<span class="token operator">-</span>11<span class="token punctuation">,</span>.col<span class="token operator">-</span>md<span class="token operator">-</span>11<span class="token punctuation">,</span>.col<span class="token operator">-</span>lg<span class="token operator">-</span>11<span class="token punctuation">,</span>
.col<span class="token operator">-</span>xs<span class="token operator">-</span>12<span class="token punctuation">,</span>.col<span class="token operator">-</span>sm<span class="token operator">-</span>12<span class="token punctuation">,</span>.col<span class="token operator">-</span>md<span class="token operator">-</span>12<span class="token punctuation">,</span>.col<span class="token operator">-</span>lg<span class="token operator">-</span>12
<span class="token punctuation">)</span></code></pre>
值得注意的是后面之一个整体字符串，因为避免编译了<code>13&gt;12</code>所以进入第三个混合
<pre class="language-less" data-language="less"><code class="language-less"><span class="token selector">.col(<span class="token variable">@index</span>, <span class="token variable">@list</span>) when (<span class="token variable">@index</span> > <span class="token variable">@grid-columns</span>)</span> <span class="token punctuation">&#123;</span>
    <span class="token selector">@&#123;list&#125;</span> <span class="token punctuation">&#123;</span>
      <span class="token property">position</span><span class="token punctuation">:</span> relative<span class="token punctuation">;</span>
      <span class="token property">min-height</span><span class="token punctuation">:</span> 1px<span class="token punctuation">;</span>
      <span class="token property">padding-left</span><span class="token punctuation">:</span>  <span class="token function">ceil</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@grid-gutter-width</span> <span class="token operator">/</span> 2<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
      <span class="token property">padding-right</span><span class="token punctuation">:</span> <span class="token function">floor</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@grid-gutter-width</span> <span class="token operator">/</span> 2<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
  <span class="token punctuation">&#125;</span></code></pre>
这里要用变量作为选择器所以要写<code>@&#123;&#125;</code>,这里相当于写了
<pre class="language-less" data-language="less"><code class="language-less"><span class="token selector">.col-xs-1,.col-sm-1,.col-md-1,.col-lg-1,
.col-xs-2,.col-sm-2,.col-md-2,.col-lg-2,
.col-xs-3,.col-sm-3,.col-md-3,.col-lg-3,
.col-xs-4,.col-sm-4,.col-md-4,.col-lg-4,
.col-xs-5,.col-sm-5,.col-md-5,.col-lg-5,
.col-xs-6,.col-sm-6,.col-md-6,.col-lg-6,
.col-xs-7,.col-sm-7,.col-md-7,.col-lg-7,
.col-xs-8,.col-sm-8,.col-md-8,.col-lg-8,
.col-xs-9,.col-sm-9,.col-md-9,.col-lg-9,
.col-xs-10,.col-sm-10,.col-md-10,.col-lg-10,
.col-xs-11,.col-sm-11,.col-md-11,.col-lg-11,
.col-xs-12,.col-sm-12,.col-md-12,.col-lg-12</span><span class="token punctuation">&#123;</span>
    <span class="token property">position</span><span class="token punctuation">:</span> relative<span class="token punctuation">;</span>
    <span class="token property">min-height</span><span class="token punctuation">:</span> 1px<span class="token punctuation">;</span>
    <span class="token property">padding-left</span><span class="token punctuation">:</span>  <span class="token function">ceil</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@grid-gutter-width</span> <span class="token operator">/</span> 2<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token property">padding-right</span><span class="token punctuation">:</span> <span class="token function">floor</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@grid-gutter-width</span> <span class="token operator">/</span> 2<span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span></code></pre> 相对位置(BFC)，最小高度，设置左右槽宽</p>
<p>这样设计的原因是：less没有循环，所以用递归的形式构造了一个大的字符串作为选择器，第一部分是递归开始，中间是递归构造部分，最后递归边界设定样式，这种构造选择器的方法值得注意！</p>
<p>然后就是三个媒体查询 <pre class="language-less" data-language="less"><code class="language-less">.<span class="token function">make-grid</span><span class="token punctuation">(</span>xs<span class="token punctuation">)</span><span class="token punctuation">;</span>         <span class="token comment">// 手机屏，下面都拦不住，先设置为默认移动端，移动端优先</span>

<span class="token atrule">@media <span class="token punctuation">(</span>min-width<span class="token punctuation">:</span> @screen-sm-min<span class="token punctuation">)</span></span> <span class="token punctuation">&#123;</span>
  <span class="token mixin-usage function">.make-grid</span><span class="token punctuation">(</span>sm<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>

<span class="token atrule">@media <span class="token punctuation">(</span>min-width<span class="token punctuation">:</span> @screen-md-min<span class="token punctuation">)</span></span> <span class="token punctuation">&#123;</span>
  <span class="token mixin-usage function">.make-grid</span><span class="token punctuation">(</span>md<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span>

<span class="token atrule">@media <span class="token punctuation">(</span>min-width<span class="token punctuation">:</span> @screen-lg-min<span class="token punctuation">)</span></span> <span class="token punctuation">&#123;</span>
  <span class="token mixin-usage function">.make-grid</span><span class="token punctuation">(</span>lg<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span></code></pre></p>
<p>然后他们都是调用了一个混合</p>
<pre class="language-less" data-language="less"><code class="language-less"><span class="token selector">.make-grid(<span class="token variable">@class</span>)</span> <span class="token punctuation">&#123;</span>
  <span class="token mixin-usage function">.float-grid-columns</span><span class="token punctuation">(</span><span class="token variable">@class</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token mixin-usage function">.loop-grid-columns</span><span class="token punctuation">(</span><span class="token variable">@grid-columns</span><span class="token punctuation">,</span> <span class="token variable">@class</span><span class="token punctuation">,</span> width<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token mixin-usage function">.loop-grid-columns</span><span class="token punctuation">(</span><span class="token variable">@grid-columns</span><span class="token punctuation">,</span> <span class="token variable">@class</span><span class="token punctuation">,</span> pull<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token mixin-usage function">.loop-grid-columns</span><span class="token punctuation">(</span><span class="token variable">@grid-columns</span><span class="token punctuation">,</span> <span class="token variable">@class</span><span class="token punctuation">,</span> push<span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token mixin-usage function">.loop-grid-columns</span><span class="token punctuation">(</span><span class="token variable">@grid-columns</span><span class="token punctuation">,</span> <span class="token variable">@class</span><span class="token punctuation">,</span> offset<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span></code></pre>
<p>他又调用了两个混合</p>
<p>第一个</p>
<pre class="language-less" data-language="less"><code class="language-less"><span class="token selector">.float-grid-columns(<span class="token variable">@class</span>)</span> <span class="token punctuation">&#123;</span>
  <span class="token selector">.col(<span class="token variable">@index</span>)</span> <span class="token punctuation">&#123;</span>
    <span class="token atrule">@item<span class="token punctuation">:</span> ~".col-@</span><span class="token punctuation">&#123;</span>class<span class="token punctuation">&#125;</span><span class="token operator">-</span>@<span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span>"<span class="token punctuation">;</span>
    <span class="token mixin-usage function">.col</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@index</span> <span class="token operator">+</span> 1<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token variable">@item</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">&#125;</span>
  <span class="token selector">.col(<span class="token variable">@index</span>, <span class="token variable">@list</span>) when (<span class="token variable">@index</span> =&lt; <span class="token variable">@grid-columns</span>)</span> <span class="token punctuation">&#123;</span>
    <span class="token atrule">@item<span class="token punctuation">:</span> ~".col-@</span><span class="token punctuation">&#123;</span>class<span class="token punctuation">&#125;</span><span class="token operator">-</span>@<span class="token punctuation">&#123;</span>index<span class="token punctuation">&#125;</span>"<span class="token punctuation">;</span>
    <span class="token mixin-usage function">.col</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@index</span> <span class="token operator">+</span> 1<span class="token punctuation">)</span><span class="token punctuation">,</span> ~<span class="token string">"@&#123;list&#125;, @&#123;item&#125;"</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">&#125;</span>
  <span class="token selector">.col(<span class="token variable">@index</span>, <span class="token variable">@list</span>) when (<span class="token variable">@index</span> > <span class="token variable">@grid-columns</span>)</span> <span class="token punctuation">&#123;</span>
    <span class="token selector">@&#123;list&#125;</span> <span class="token punctuation">&#123;</span>
      <span class="token property">float</span><span class="token punctuation">:</span> left<span class="token punctuation">;</span>
    <span class="token punctuation">&#125;</span>
  <span class="token punctuation">&#125;</span>
  .<span class="token function">col</span><span class="token punctuation">(</span>1<span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span></code></pre>
<p>和之前那个<code>.make-grid-columns()</code>一样，只不过这次指定了类型，最后相当于设置了一个左浮动</p>
<p>第二个，默认<code>@grid-columns：12</code> <pre class="language-less" data-language="less"><code class="language-less"><span class="token selector">.loop-grid-columns(<span class="token variable">@index</span>, <span class="token variable">@class</span>, <span class="token variable">@type</span>) when (<span class="token variable">@index</span> >= 0)</span> <span class="token punctuation">&#123;</span>
  <span class="token mixin-usage function">.calc-grid-column</span><span class="token punctuation">(</span><span class="token variable">@index</span><span class="token punctuation">,</span> <span class="token variable">@class</span><span class="token punctuation">,</span> <span class="token variable">@type</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token mixin-usage function">.loop-grid-columns</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@index</span> <span class="token operator">-</span> 1<span class="token punctuation">)</span><span class="token punctuation">,</span> <span class="token variable">@class</span><span class="token punctuation">,</span> <span class="token variable">@type</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span></code></pre>
相当于给<strong>0</strong>-12(注意不是<strong>1</strong>-12)设置<code>.calc-grid-column(@index, @class, @type)</code></p>
<pre class="language-less" data-language="less"><code class="language-less"><span class="token selector">.calc-grid-column(<span class="token variable">@index</span>, <span class="token variable">@class</span>, <span class="token variable">@type</span>) when (<span class="token variable">@type</span> = width) and (<span class="token variable">@index</span> > 0)</span> <span class="token punctuation">&#123;</span>
  <span class="token selector">.col-@&#123;class&#125;-@&#123;index&#125;</span> <span class="token punctuation">&#123;</span>
    <span class="token property">width</span><span class="token punctuation">:</span> <span class="token function">percentage</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@index</span> <span class="token operator">/</span> <span class="token variable">@grid-columns</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">&#125;</span>
<span class="token punctuation">&#125;</span>
<span class="token selector">.calc-grid-column(<span class="token variable">@index</span>, <span class="token variable">@class</span>, <span class="token variable">@type</span>) when (<span class="token variable">@type</span> = push) and (<span class="token variable">@index</span> > 0)</span> <span class="token punctuation">&#123;</span>
  <span class="token selector">.col-@&#123;class&#125;-push-@&#123;index&#125;</span> <span class="token punctuation">&#123;</span>
    <span class="token property">left</span><span class="token punctuation">:</span> <span class="token function">percentage</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@index</span> <span class="token operator">/</span> <span class="token variable">@grid-columns</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">&#125;</span>
<span class="token punctuation">&#125;</span>
<span class="token selector">.calc-grid-column(<span class="token variable">@index</span>, <span class="token variable">@class</span>, <span class="token variable">@type</span>) when (<span class="token variable">@type</span> = push) and (<span class="token variable">@index</span> = 0)</span> <span class="token punctuation">&#123;</span>
  <span class="token selector">.col-@&#123;class&#125;-push-0</span> <span class="token punctuation">&#123;</span>
    <span class="token property">left</span><span class="token punctuation">:</span> auto<span class="token punctuation">;</span>
  <span class="token punctuation">&#125;</span>
<span class="token punctuation">&#125;</span>
<span class="token selector">.calc-grid-column(<span class="token variable">@index</span>, <span class="token variable">@class</span>, <span class="token variable">@type</span>) when (<span class="token variable">@type</span> = pull) and (<span class="token variable">@index</span> > 0)</span> <span class="token punctuation">&#123;</span>
  <span class="token selector">.col-@&#123;class&#125;-pull-@&#123;index&#125;</span> <span class="token punctuation">&#123;</span>
    <span class="token property">right</span><span class="token punctuation">:</span> <span class="token function">percentage</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@index</span> <span class="token operator">/</span> <span class="token variable">@grid-columns</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">&#125;</span>
<span class="token punctuation">&#125;</span>
<span class="token selector">.calc-grid-column(<span class="token variable">@index</span>, <span class="token variable">@class</span>, <span class="token variable">@type</span>) when (<span class="token variable">@type</span> = pull) and (<span class="token variable">@index</span> = 0)</span> <span class="token punctuation">&#123;</span>
  <span class="token selector">.col-@&#123;class&#125;-pull-0</span> <span class="token punctuation">&#123;</span>
    <span class="token property">right</span><span class="token punctuation">:</span> auto<span class="token punctuation">;</span>
  <span class="token punctuation">&#125;</span>
<span class="token punctuation">&#125;</span>
<span class="token selector">.calc-grid-column(<span class="token variable">@index</span>, <span class="token variable">@class</span>, <span class="token variable">@type</span>) when (<span class="token variable">@type</span> = offset)</span> <span class="token punctuation">&#123;</span>
  <span class="token selector">.col-@&#123;class&#125;-offset-@&#123;index&#125;</span> <span class="token punctuation">&#123;</span>
    <span class="token property">margin-left</span><span class="token punctuation">:</span> <span class="token function">percentage</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token variable">@index</span> <span class="token operator">/</span> <span class="token variable">@grid-columns</span><span class="token punctuation">)</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  <span class="token punctuation">&#125;</span>
<span class="token punctuation">&#125;</span></code></pre>
<p>分别是：</p>
<p>设置宽度，左列排序，左特判，右列排序，右特判，列偏移</p>
<p>切记这里排序的时候0的时候是auto不是0</p>
<p>排序和偏移的区别就是排序是按正常顺序排序，偏移之对特殊元素处理</p>
<h2 id="bootstrap-实例">Bootstrap 实例</h2>
<p>尝试制作BootStrap中文站首页四个图片可以上下的特效</p>
<p>我们知道这种样式bootstrap官网一定会提供组件的，<a
target="_blank" rel="noopener" href="https://v3.bootcss.com/components/#thumbnails-custom-content">链接</a></p>
<p>直接套用略作样式修改</p>
<pre class="language-html" data-language="html"><code class="language-html"><span class="token doctype"><span class="token punctuation">&lt;!</span><span class="token doctype-tag">DOCTYPE</span> <span class="token name">html</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>head</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">charset</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>UTF-8<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>viewport<span class="token punctuation">"</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>width=device-width, initial-scale=1.0<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>link</span> <span class="token attr-name">rel</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>stylesheet<span class="token punctuation">"</span></span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>../bootstrap/css/bootstrap.min.css<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>style</span><span class="token punctuation">></span></span><span class="token style"><span class="token language-css">
        <span class="token selector">.caption</span><span class="token punctuation">&#123;</span><span class="token property">text-align</span><span class="token punctuation">:</span> center<span class="token punctuation">;</span><span class="token punctuation">&#125;</span>
        <span class="token selector">.caption h3</span><span class="token punctuation">&#123;</span><span class="token property">color</span><span class="token punctuation">:</span>#337ab7<span class="token punctuation">;</span><span class="token punctuation">&#125;</span>
        <span class="token selector">.caption h4</span><span class="token punctuation">&#123;</span><span class="token property">font-size</span><span class="token punctuation">:</span>15.6px<span class="token punctuation">;</span><span class="token property">color</span><span class="token punctuation">:</span>#777<span class="token punctuation">;</span><span class="token punctuation">&#125;</span>
        <span class="token selector">.caption</span><span class="token punctuation">&#123;</span><span class="token property">color</span><span class="token punctuation">:</span> #555<span class="token punctuation">;</span><span class="token punctuation">&#125;</span>
        <span class="token selector">.thumbnail</span><span class="token punctuation">&#123;</span><span class="token property">height</span><span class="token punctuation">:</span> 326px<span class="token punctuation">;</span><span class="token punctuation">&#125;</span>
    </span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>style</span><span class="token punctuation">></span></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>head</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>body</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>container<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>row<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>col-sm-6 col-md-4 col-lg-3<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>thumbnail<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>./img/expo.png<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>caption<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h3</span><span class="token punctuation">></span></span>优站精选<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h3</span><span class="token punctuation">></span></span>
                        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h4</span><span class="token punctuation">></span></span>Bootstrap 网站实例<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h4</span><span class="token punctuation">></span></span>
                        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span>Bootstrap 优站精选频道收集了众多基于 Bootstrap 构建、设计精美的、有创意的网站。<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>col-sm-6 col-md-4 col-lg-3<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>thumbnail<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>./img/webpack.png<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>caption<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h3</span><span class="token punctuation">></span></span>Webpack<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h3</span><span class="token punctuation">></span></span>
                        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h4</span><span class="token punctuation">></span></span>是前端资源模块化管理和打包工具<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h4</span><span class="token punctuation">></span></span>
                        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span>Webpack 是当下最热门的前端资源模块化管理和打包工具。它可以将许多松散的模块按照依赖和规则打包成符合生产环境部署的前端资源。<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>col-sm-6 col-md-4 col-lg-3<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>thumbnail<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>./img/react.png<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>caption<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h3</span><span class="token punctuation">></span></span>React<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h3</span><span class="token punctuation">></span></span>
                        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h4</span><span class="token punctuation">></span></span>用于构建用户界面的 JavaScript 框架<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h4</span><span class="token punctuation">></span></span>
                        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span>React 起源于 Facebook 的内部项目，是一个用于构建用户界面的 JavaScript 库。<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>col-sm-6 col-md-4 col-lg-3<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>thumbnail<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>./img/typescript.png<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>caption<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h3</span><span class="token punctuation">></span></span>TypeScript<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h3</span><span class="token punctuation">></span></span>
                        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h4</span><span class="token punctuation">></span></span>中文手册<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h4</span><span class="token punctuation">></span></span>
                        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span>TypeScript 是由微软开源的编程语言。它是 JavaScript 的一个超集，而且本质上向这个语言添加了可选的静态类型和基于类的面向对象编程。<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>body</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>../bootstrap/js/jquery-3.5.1.min.js<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token script"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>../bootstrap/js/bootstrap.js<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token script"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>html</span><span class="token punctuation">></span></span></code></pre>
<p><strong>一定要注意的是</strong>：因为我们是一级一级的往下掉，所以必须把lg,md,sm全写一边，任何一个都不能少</p>
<p><strong>还要注意</strong>：BootStrap是三端同步，所以一定要加上视口</p>
<pre class="language-html" data-language="html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">name</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>viewport<span class="token punctuation">"</span></span> <span class="token attr-name">content</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>width=device-width, initial-scale=1.0<span class="token punctuation">"</span></span><span class="token punctuation">></span></span></code></pre>
<h2 id="bootstrap-的列排序和列偏移">BootStrap 的列排序和列偏移</h2>
<p>在上一节的基础上，我们希望可以实现当网页宽度变小的时候原本是尾部先下去改头先下去(明显修改float即可)我们尝试使用列排序和偏移实现</p>
<p>我们的思路是，不管怎么修改，最开始掉下来的肯定是html代码中在最后的元素，所以我们要把所有元素都反着写,所以，结构方面的位置就已经卡死了，我们希望修改css的样式从而敢于网页的表现形式</p>
<p>我们考虑css端的表达，我们知道刚刚源码的列排序都是正数没有负数，所以只能是右面往左推，于是给最右面那个元素写下<code>class="col-lg-pull-9"</code>
相当于是从右往左偏移了9/12，于是最后一个位置上的元素就到了首位，并且重合，于是同理修改其他元素</p>
<p>剩下的2种情况也要考虑</p>
<p>于是得到代码如下</p>
<pre class="language-html" data-language="html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>container<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>row<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>col-sm-6 col-md-4 col-lg-3 col-lg-push-9 col-md-push-8 col-sm-push-6<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>thumbnail<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>./img/typescript.png<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>caption<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h3</span><span class="token punctuation">></span></span>TypeScript<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h3</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h4</span><span class="token punctuation">></span></span>中文手册<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h4</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span>TypeScript 是由微软开源的编程语言。它是 JavaScript 的一个超集，而且本质上向这个语言添加了可选的静态类型和基于类的面向对象编程。<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>col-sm-6 col-md-4 col-lg-3 col-lg-push-3 col-sm-pull-6<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>thumbnail<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>./img/react.png<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>caption<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h3</span><span class="token punctuation">></span></span>React<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h3</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h4</span><span class="token punctuation">></span></span>用于构建用户界面的 JavaScript 框架<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h4</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span>React 起源于 Facebook 的内部项目，是一个用于构建用户界面的 JavaScript 库。<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>col-sm-6 col-md-4 col-lg-3 col-lg-pull-3 col-md-pull-8<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>thumbnail<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>./img/webpack.png<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>caption<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h3</span><span class="token punctuation">></span></span>Webpack<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h3</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h4</span><span class="token punctuation">></span></span>是前端资源模块化管理和打包工具<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h4</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span>Webpack 是当下最热门的前端资源模块化管理和打包工具。它可以将许多松散的模块按照依赖和规则打包成符合生产环境部署的前端资源。<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>col-sm-6 col-md-4 col-lg-3 col-lg-pull-9<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>thumbnail<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>./img/expo.png<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>caption<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h3</span><span class="token punctuation">></span></span>优站精选<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h3</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h4</span><span class="token punctuation">></span></span>Bootstrap 网站实例<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h4</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span>Bootstrap 优站精选频道收集了众多基于 Bootstrap 构建、设计精美的、有创意的网站。<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></code></pre>
<p>在写完之后发现出锅了,在md的情况下原来正常但是写完sm之后就不正常了</p>
<p>发现出锅的是React部分,这是因为我们的宽度没有达到lg,所以根据移动端优先的原则,媒体查询被sm截掉了,于是就出现了列排序,所以我们要显式指定md状态下的列偏移为0,这就是为什么当时源码是<code>&gt;=0'而不是</code>&gt;0`</p>
<pre class="language-html" data-language="html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>container<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>row<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>col-sm-6 col-md-4 col-lg-3 col-lg-push-9 col-md-push-8 col-sm-push-6<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>thumbnail<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>./img/typescript.png<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>caption<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h3</span><span class="token punctuation">></span></span>TypeScript<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h3</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h4</span><span class="token punctuation">></span></span>中文手册<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h4</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span>TypeScript 是由微软开源的编程语言。它是 JavaScript 的一个超集，而且本质上向这个语言添加了可选的静态类型和基于类的面向对象编程。<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>col-sm-6 col-md-4 col-lg-3 col-lg-push-3 col-md-pull-0 col-sm-pull-6<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>thumbnail<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>./img/react.png<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>caption<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h3</span><span class="token punctuation">></span></span>React<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h3</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h4</span><span class="token punctuation">></span></span>用于构建用户界面的 JavaScript 框架<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h4</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span>React 起源于 Facebook 的内部项目，是一个用于构建用户界面的 JavaScript 库。<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>col-sm-6 col-md-4 col-lg-3 col-lg-pull-3 col-md-pull-8 col-sm-pull-0<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>thumbnail<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>./img/webpack.png<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>caption<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h3</span><span class="token punctuation">></span></span>Webpack<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h3</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h4</span><span class="token punctuation">></span></span>是前端资源模块化管理和打包工具<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h4</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span>Webpack 是当下最热门的前端资源模块化管理和打包工具。它可以将许多松散的模块按照依赖和规则打包成符合生产环境部署的前端资源。<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>col-sm-6 col-md-4 col-lg-3 col-lg-pull-9 col-md-pull-0 col-sm-pull-0<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>thumbnail<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>img</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>./img/expo.png<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>caption<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h3</span><span class="token punctuation">></span></span>优站精选<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h3</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h4</span><span class="token punctuation">></span></span>Bootstrap 网站实例<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h4</span><span class="token punctuation">></span></span>
                    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span>Bootstrap 优站精选频道收集了众多基于 Bootstrap 构建、设计精美的、有创意的网站。<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>
                <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
            <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></code></pre>
<p>换而言之就是:
可以有偏移,但是同种偏移必须<strong>不能跳着写</strong></p>
<h2 id="bootstrap-的响应式工具读源码学工具">BootStrap
的响应式工具[读源码学工具]</h2>
<p>BootStrap
的响应是工具是以珊格布局为基础的,所以要加在珊格布局的里面,还需新增文件<code>responsive-utilities.less</code>与<code>/mixin/grid-framework.less</code>,前者是主文件</p>
<p>最开始的模块是 <pre class="language-less" data-language="less"><code class="language-less"><span class="token selector">.visible-xs,
.visible-sm,
.visible-md,
.visible-lg</span> <span class="token punctuation">&#123;</span>
  <span class="token mixin-usage function">.responsive-invisibility</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span></code></pre>
去找<code>responsive-invisibility()</code></p>
<pre class="language-less" data-language="less"><code class="language-less"><span class="token selector">.responsive-invisibility()</span> <span class="token punctuation">&#123;</span>
  <span class="token property">display</span><span class="token punctuation">:</span> none <span class="token important">!important</span><span class="token punctuation">;</span>
<span class="token punctuation">&#125;</span></code></pre>
<p>强制所有的元素全部隐藏</p>
<p>所以我们可以尝试使用 <code>visiable-xs</code> <pre class="language-html" data-language="html"><code class="language-html"><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>container visible-md<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>jumbotron<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span><span class="token punctuation">></span></span>Hello, world!<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span>...<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>
        <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>p</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>a</span> <span class="token attr-name">class</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>btn btn-primary btn-lg<span class="token punctuation">"</span></span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>#<span class="token punctuation">"</span></span> <span class="token attr-name">role</span><span class="token attr-value"><span class="token punctuation attr-equals">=</span><span class="token punctuation">"</span>button<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Learn more<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>a</span><span class="token punctuation">></span></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>p</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span></code></pre></p>
<p>发现只有在md状态下可见</p>
<p>与之相反的是<code>hidden-xx</code>,意思相反不解释</p>
<h2 id="珊格模型设计的精妙之处">珊格模型设计的精妙之处</h2>
<p>写一个珊格系统,F12查属性,外层容器有一个 <pre class="language-css" data-language="css"><code class="language-css"><span class="token property">padding-right</span><span class="token punctuation">:</span> 15px<span class="token punctuation">;</span>
<span class="token property">padding-left</span><span class="token punctuation">:</span> 15px<span class="token punctuation">;</span>
<span class="token property">margin-right</span><span class="token punctuation">:</span> auto<span class="token punctuation">;</span>
<span class="token property">margin-left</span><span class="token punctuation">:</span> auto<span class="token punctuation">;</span></code></pre>
最后两行就是一个居中,然后就是<strong>容器的两边给了一个padding15</strong></p>
<p>看到<code>.row</code>属性,看到如下命令 <pre class="language-css" data-language="css"><code class="language-css"><span class="token property">margin-right</span><span class="token punctuation">:</span> -15px<span class="token punctuation">;</span>
<span class="token property">margin-left</span><span class="token punctuation">:</span> -15px<span class="token punctuation">;</span></code></pre></p>
<p>看任意一个列,可以看到有 <pre class="language-css" data-language="css"><code class="language-css"><span class="token property">padding-right</span><span class="token punctuation">:</span> 15px<span class="token punctuation">;</span>
<span class="token property">padding-left</span><span class="token punctuation">:</span> 15px<span class="token punctuation">;</span></code></pre> 是做槽宽的</p>
<p>得到</p>
<ul>
<li>固定容器两边有15px的padding</li>
<li>row 两边有-15px的margin</li>
<li>col 两边有15px的padding</li>
</ul>
<p>原理</p>
<ul>
<li>为了维护槽宽的规则,列两边必须要有15px的padding</li>
<li>正常情况下这是可以的,但是考虑一种情况,在列里面我想加一个行</li>
<li>由于列自带槽宽,行没有办法占据整个列,这样,在行里面再加入列,边缘相当于有45px的槽宽</li>
<li>我们如果给行加入-15px就可以抵消45px的异常槽宽</li>
<li>但是产生了的问题是最外层的那个固定容器套的行也有一个负槽宽</li>
<li>解决方案是给固定容器加入槽宽15</li>
</ul>
<p><strong>思想</strong>:
为了解决问题我们修改了行列的边距,但是会影响到最外层,因为最外层的固定容器不是行列容器,<strong>是一个特殊化的元素</strong>,我们的思想是把他<strong>一般化</strong>,也就是在当前问题上具有与col,row一样的属性,也就是槽宽15</p>
<h2 id="bootstrap-定制化">BootStrap 定制化</h2>
<ul>
<li>To C 面向客户的(eg 电商),这类项目要自己写</li>
<li>To B 面向公司内网的(eg OA),直接从网上下载类似的UI库直接用</li>
</ul>
<p>有的需求要求有自己的风格,直接修改bootstrap源码是可以的,但是不利于维护,所以我们可以再写一个less,然后import源码的bootstrap.less
然后在后面修改变量值,编译自己写的less</p>
<p>p.s. 在H5中<code>dara-</code>开头的大多数JS,</p>

    </div>

    
    
    
      


    <footer class="post-footer">
          <div class="reward-container">
  <div></div>
  <button>
    赞赏
  </button>
  <div class="post-reward">
      <div>
        <img src="/images/wechatpay.png" alt="Liu Kairui 微信">
        <span>微信</span>
      </div>
      <div>
        <img src="/images/alipay.png" alt="Liu Kairui 支付宝">
        <span>支付宝</span>
      </div>

  </div>
</div>

          

<div class="post-copyright">
<ul>
  <li class="post-copyright-author">
      <strong>本文作者： </strong>Liu Kairui
  </li>
  <li class="post-copyright-link">
      <strong>本文链接：</strong>
      <a href="http://liukairui.me/article/BootStrap%E7%AC%94%E8%AE%B0/" title="BootStrap 笔记">http://liukairui.me/article/BootStrap笔记/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" rel="noopener" target="_blank"><i class="fab fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！
  </li>
</ul>
</div>

          <div class="post-tags">
              <a href="/tags/%E5%89%8D%E7%AB%AF/" rel="tag"><i class="fa fa-tag"></i> 前端</a>
              <a href="/tags/%E7%AC%94%E8%AE%B0/" rel="tag"><i class="fa fa-tag"></i> 笔记</a>
              <a href="/tags/CSS/" rel="tag"><i class="fa fa-tag"></i> CSS</a>
              <a href="/tags/BootStrap/" rel="tag"><i class="fa fa-tag"></i> BootStrap</a>
          </div>

        

          <div class="post-nav">
            <div class="post-nav-item">
                <a href="/article/HTML&CSS%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/" rel="prev" title="HTML&CSS学习笔记">
                  <i class="fa fa-chevron-left"></i> HTML&CSS学习笔记
                </a>
            </div>
            <div class="post-nav-item">
                <a href="/article/Canvas%E5%AD%A6%E4%B9%A0%E7%AC%94%E8%AE%B0/" rel="next" title="Canvas学习笔记">
                  Canvas学习笔记 <i class="fa fa-chevron-right"></i>
                </a>
            </div>
          </div>
    </footer>
  </article>
</div>






    <div class="comments" id="valine-comments"></div>
</div>
  </main>

  <footer class="footer">
    <div class="footer-inner">


<div class="copyright">
  &copy; 2019 – 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Liu Kairui</span>
</div>
<div class="busuanzi-count">
    <span class="post-meta-item" id="busuanzi_container_site_uv">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-item" id="busuanzi_container_site_pv">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" rel="noopener" target="_blank">Hexo</a> & <a href="https://theme-next.js.org/muse/" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>
  <div class="addthis_inline_share_toolbox">
    <script src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-6231eb6f709fc868" async="async"></script>
  </div><script
  async
  src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"
></script>

 
<script src="https://cdn.jsdelivr.net/npm/moment@2.22.2/moment.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/moment-precise-range-plugin@1.3.0/moment-precise-range.min.js"></script>
<script>
  function timer() {
    var ages = moment.preciseDiff(moment(),moment(20201101,"YYYYMMDD"));
    ages = ages.replace(/years?/, "年");
    ages = ages.replace(/months?/, "月");
    ages = ages.replace(/days?/, "天");
    ages = ages.replace(/hours?/, "小时");
    ages = ages.replace(/minutes?/, "分");
    ages = ages.replace(/seconds?/, "秒");
    ages = ages.replace(/\d+/g, '<span class="daysCnt" style="color:#1890ff">$&</span>');
    div.innerHTML = `我已在此等候你 ${ages}`;
    div.className="workDays";
  }
  var div = document.createElement("div");
  //插入到copyright之后
  var copyright = document.querySelector(".copyright");
  document.querySelector(".footer-inner").insertBefore(div, copyright.nextSibling);
  timer();
  setInterval("timer()",1000)
</script>



    </div>
  </footer>

  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js"></script>
  <script src="https://cdn.jsdelivr.net/npm/@next-theme/pjax@0.5.0/pjax.min.js" integrity="sha256-3NkoLDrmHLTYj7csHIZSr0MHAFTXth7Ua/DDt4MRUAg=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js" integrity="sha256-yt2kYMy0w8AbtF89WXb2P1rfjcP/HTHLT7097U8Y5b8=" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/lozad.js/1.16.0/lozad.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/pangu/4.0.7/pangu.min.js"></script>
<script src="/js/comments.js"></script><script src="/js/utils.js"></script><script src="/js/motion.js"></script><script src="/js/schemes/muse.js"></script><script src="/js/next-boot.js"></script><script src="/js/pjax.js"></script>

  
<script src="https://cdn.jsdelivr.net/npm/hexo-generator-searchdb@1.4.0/dist/search.js" integrity="sha256-vXZMYLEqsROAXkEw93GGIvaB2ab+QW6w3+1ahD9nXXA=" crossorigin="anonymous"></script>
<script src="/js/third-party/search/local-search.js"></script>


  <script class="next-config" data-name="mermaid" type="application/json">{"enable":true,"theme":"forest","js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mermaid/8.14.0/mermaid.min.js","integrity":"sha256-7wT34TI0pEBeEFoi4z+vhuSddGh6vUTMWdqJ2SDe2jg="}}</script>
  <script src="/js/third-party/tags/mermaid.js"></script>

  <script src="/js/third-party/fancybox.js"></script>

  <script src="/js/third-party/pace.js"></script>

  
  <script data-pjax async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>


  <script class="next-config" data-name="leancloud_visitors" type="application/json">{"enable":true,"app_id":"ABKlVtS4cyaWYEwunPyK3sXt-9Nh9j0Va","app_key":"xxGXdTTEGEVifs2TLB35844I","server_url":"https://abklvts4.lc-cn-e1-shared.com","security":false}</script>
  <script src="/js/third-party/statistics/lean-analytics.js"></script>


  

  <script class="next-config" data-name="enableMath" type="application/json">true</script><script class="next-config" data-name="mathjax" type="application/json">{"enable":true,"tags":"none","mhchem":true,"js":{"url":"https://cdnjs.cloudflare.com/ajax/libs/mathjax/3.2.0/es5/tex-mml-chtml.min.js"}}</script>
<script src="/js/third-party/math/mathjax.js"></script>


  <script src="https://cdnjs.cloudflare.com/ajax/libs/quicklink/2.2.0/quicklink.umd.js" integrity="sha256-4kQf9z5ntdQrzsBC3YSHnEz02Z9C1UeW/E9OgnvlzSY=" crossorigin="anonymous"></script>
  <script class="next-config" data-name="quicklink" type="application/json">{"enable":true,"home":false,"archive":false,"delay":true,"timeout":3000,"priority":true,"url":"http://liukairui.me/article/BootStrap%E7%AC%94%E8%AE%B0/"}</script>
  <script src="/js/third-party/quicklink.js"></script>
<script src="https://cdn.jsdelivr.net/npm/darkmode-js@1.5.7/lib/darkmode-js.min.js"></script>

<script>
var options = {
  bottom: '64px',
  right: 'unset',
  left: '32px',
  time: '0.5s',
  mixColor: 'transparent',
  backgroundColor: 'transparent',
  buttonColorDark: '#100f2c',
  buttonColorLight: '#fff',
  saveInCookies: true,
  label: '🌓',
  autoMatchOsTheme: true
}
const darkmode = new Darkmode(options);
window.darkmode = darkmode;
darkmode.showWidget();
</script>


<script class="next-config" data-name="valine" type="application/json">{"enable":true,"appId":"ABKlVtS4cyaWYEwunPyK3sXt-9Nh9j0Va","appKey":"xxGXdTTEGEVifs2TLB35844I","serverURLs":"https://abklvts4.lc-cn-e1-shared.com","placeholder":"请开始你的表演","avatar":"identicon","meta":["nick","mail","link"],"pageSize":10,"lang":"zh-CN","visitor":false,"comment_count":true,"recordIP":true,"enableQQ":true,"requiredFields":[],"el":"#valine-comments","path":"/article/BootStrap%E7%AC%94%E8%AE%B0/"}</script>
<script>
document.addEventListener('page:loaded', () => {
  NexT.utils.loadComments(CONFIG.valine.el)
    .then(() => NexT.utils.getScript(
      'https://cdn.jsdelivr.net/npm/valine@1.4.14/dist/Valine.min.js',
      { condition: window.Valine }
    ))
    .then(() => {
      new Valine(CONFIG.valine);
    });
});
</script>


  <script async src="/js/fireworks.js"></script>




  <script src="/js/activate-power-mode.min.js"></script>
  <script>
    POWERMODE.colorful = true;
    POWERMODE.shake = false;
    document.body.addEventListener('input', POWERMODE);
  </script>




  <script src="/js/wobblewindow.js"></script>
  <script>
    //只在桌面版网页启用特效 记得同步到header.njk
    if( window.innerWidth > 768  ){
      $(document).ready(function () {
        
          $('body>main>header').wobbleWindow({
            radius: 50,
            movementTop: false,
            movementLeft: false,
            movementRight: false,
            debug: false,
          });
        

        //
        //  $('body header>aside').wobbleWindow({
        //    radius: 50,
        //    movementLeft: false,
        //    movementTop: false,
        //    movementBottom: false,
        //    position: 'fixed',
        //    debug: false,
        //  });
        //

        
          $('body>footer').wobbleWindow({
            radius: 50,
            movementBottom: false,
            movementLeft: false,
            movementRight: false,
            debug: false,
          });
        
      });
    }
  </script>


 
<script>
  $(document).ready(function(){
    var beian = document.querySelector(".footer-inner > .beian > a");
    var cpr=document.querySelector(".footer-inner > .copyright");
    var cnz=document.querySelector(".workDays");//.parentNode;
    var bsz=document.querySelector(".busuanzi-count");
    if(cnz!=null&&bsz!=null)
      cnz.parentNode.insertBefore(bsz,cnz);
    if(bsz == null || bsz == undefined || document.querySelector("#busuanzi_value_site_pv").innerText=="" || document.querySelector("#busuanzi_value_site_uv").innerText == "")
      bsz.remove();
    checkIndex();
    if(beian){cpr.classList.add('split-line');cpr.appendChild(beian);}
  })
  $(document).on('pjax:complete',checkIndex);
</script>



<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"log":false,"model":{"jsonPath":"/live2dw/assets/hijiki.model.json"},"display":{"position":"right","width":150,"height":300},"mobile":{"show":false},"react":{"opacity":0.7}});</script></body>
</html>
